<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
<button onclick="goBefore()">前一天</button>
<button onclick="goAfter()">后一天</button>
<div id="app"></div>
<script>
  var date = new Date();
  var app = document.getElementById("app");
  app.innerHTML = myGetDate(date);
  //获取时间戳
  var time = date.getTime();//当前的毫秒数
  var oneDay = ***;//一天的毫秒数
  //前一天
  function goBefore(){
    var before = time - oneDay;//计算前一天的毫秒数
    date.setTime(before);
    app.innerHTML = myGetDate(date);
  }
  //后一天
  function goAfter(){
    var after = time + oneDay;//计算前一天的毫秒数
    date.setTime(after);
    app.innerHTML = myGetDate(date);
  }
  //封装日期格式化的方法
  function myGetDate(d){
    return `${d.getFullYear()}年${d.getMonth()+}月${d.getDate()}日`;
  }
</script>
</body>
</html>
